Component({
  properties: {
    title: {
      type: String,
      value: "",
    },
    storeOptions: {
      type: Array,
      value: [],
    },
    showModal: {
      type: Boolean,
      value: false,
    },
  },

  methods: {
    closeModal: function () {
      this.triggerEvent("close");
    },

    selectOption: function (e) {
      const selectedId = e.currentTarget.dataset.id;
      this.setData({ selectedId });
    },

    onConfirm: function () {
      const selectedId = this.data.selectedId;
      if (selectedId !== undefined) {
        this.triggerEvent("confirm", { selectedId });
        this.closeModal();
      } else {
        wx.showToast({
          title: "请选择一个店铺",
          icon: "none",
        });
      }
    },
  },
});
